#include<stdio.h>
#include<limits.h>

int main(void) {
    while (1) {
        char string[1001];
        int len;
        if (len = scanf(" %s", string), len == EOF || len == 0) {
            break;
        }
        
        // C1, C2, C3...
        int count[26] = {0};
        char* pnt = string;
        while (*pnt != '\0') {
            count[*pnt - 'a']++;
            pnt++;
        }
        
        // C中值出现次数
        int count_num[1000] = {0};
        for (int i = 0; i < 26; i++) {
            count_num[count[i]]++;
        }
        
        int max_count = 0;
        // 最大C中出现次数
        int max = 0;
        for (int i = 1; i < 1000; i++) {
            if (count_num[i] > max && count_num[i] > 0) {
                max = count_num[i];
                max_count = i;
            }
        }
        
        printf("%d", max_count);
        for (int i = 0; i < 26; i++) {
            if (count[i] == max_count) {
                printf(" %c", (char)('a' + i));
            }
        }
        putchar('\n');
    }
     return 0;
}

